﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace House_Control
{
    class SmokeDetector : Alarm
    {
        //We need this variable for when we call the base class constructor.
        static int alarmType = Alarm.SMOKE;
        public SmokeDetector(int roomNo) : base(alarmType, roomNo)
        {
        }
        static Random rnd = new Random();
        private int batLife = rnd.Next(20, 100);
        public const int LOWBATLEVEL = 10;
        public Boolean lowBat = false;
        public String lastAlert = "Never";
        public int getBatLife() 
        {
            return batLife;
        }
        public void setBatLife(int batLife)
        {
            this.batLife = batLife;
            if (batLife < LOWBATLEVEL)
            {
                lowBat = true;
                log.append("Battery life for smoke detector in room " + base.getRoomNo() + " less than " + LOWBATLEVEL + "%. Change immediately!");
                MessageBox.Show("BEEP!!");
            }
            else
                lowBat = false;
        }
        public void trip()
        {
            tripped = true;
            log.append("Smoke Detector for room number " + base.getRoomNo() + " is detecting smoke!");
            MessageBox.Show("BEEP!! BEEP!! BEEP!! BEEP!! BEEP!! BEEP!! BEEP!!");
            callOwner();
            lastAlert = DateTime.Now.ToString();
        }
    }
}
